package com.gnote.controller;

import lombok.RequiredArgsConstructor;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.PromptChatMemoryAdvisor;
import org.springframework.ai.chat.memory.ChatMemory;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/structure")
@RequiredArgsConstructor
public class StructureController {
    private final ChatClient.Builder chatClientBuild;
    private final ChatMemory chatMemory;

    @GetMapping(value = "/test", produces = "text/stream;charset=UTF-8")
    public String test(String msg) {
        ChatClient chatClient = chatClientBuild.defaultAdvisors(
                PromptChatMemoryAdvisor.builder(chatMemory).build()
        ).build();
        Boolean entity = chatClient.prompt()
                .system("请判断用户消息是否是投诉只能用true或false回答,不要输出多余内容")
                .user(msg).call().entity(Boolean.class);
        return entity.toString();
    }


}
